package org.music.generate.model;

import org.apache.commons.lang3.StringUtils;

import java.util.*;

/**
 * Created by mingdongc on 2017/3/8.
 */
public class TableMetaData{
    final static Map<String,String> importMap;
    static {
        importMap=new HashMap<String,String>();
        importMap.put("Date","java.util.Date");
        importMap.put("BigDecimal","java.math.BigDecimal");
    }
    private List<ColumnMetaData> columnMetaDatas;
    private Set<String> imports=new HashSet<>();
    public TableMetaData(List<ColumnMetaData> columnMetaDatas){
        this.columnMetaDatas=new ArrayList<ColumnMetaData>();
        for(ColumnMetaData columnMetaData:columnMetaDatas){

            if(StringUtils.endsWithAny(columnMetaData.getJavaName(),"id","delFlag","createBy","updateBy","createTime","updateTime","remarks")){
                continue;
            }
            this.columnMetaDatas.add(columnMetaData);
            if(importMap.containsKey(columnMetaData.getJavaTypeName())){
                imports.add(importMap.get(columnMetaData.getJavaTypeName()));
            }
        }
    }

    public List<ColumnMetaData> getColumnMetaDatas() {
        return columnMetaDatas;
    }

    public void setColumnMetaDatas(List<ColumnMetaData> columnMetaDatas) {
        this.columnMetaDatas = columnMetaDatas;
    }

    public Set<String> getImports() {
        return imports;
    }

    public void setImports(Set<String> imports) {
        this.imports = imports;
    }
}
